'use strict';

const puppeteer = require('puppeteer');
// const devices = require('puppeteer/DeviceDescriptors');


(async () => {
	const browser = await puppeteer.launch({headless:false,});
	const page =  await browser.newPage();
	await page.goto('https://www.taobao.com/');
	let scrollEnable = true;
	let scrollStep = 10; //每次滚动的步长
	while (scrollEnable) {
		scrollEnable = await page.evaluate((scrollStep) => {
		 	let scrollTop = document.scrollingElement.scrollTop;
		 	document.scrollingElement.scrollTop = scrollTop + scrollStep;
		 	return document.body.clientHeight > scrollTop + 1080 ? true : false
	 	}, scrollStep);
	 	await page.waitFor(100);
	}
	await page.waitFor(2000)
  	await page.screenshot({path: 'taobao.png'});
  	await browser.close();
})();



			